<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="批准文号">
              <a-input placeholder="请输入批准文号" v-model="queryParam.yid"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="药品名称">
              <a-input placeholder="请输入药品名称" @blur="ynamefun" v-model="queryParams.yname"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <div class="table-operator">
<!--      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
      <a-button type="primary" icon="download" @click="handleExportXls('药品报损单表')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">审核</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.bid)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <MedicineExamineLossModal ref="modalForm" @ok="modalFormOk"></MedicineExamineLossModal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import MedicineExamineLossModal from '../examine/modules/MedicineExamineLossModal'
  import JDate from '@/components/jeecg/JDate.vue'

  export default {
    name: "MedicineExamineLossList",
    mixins:[JeecgListMixin],
    components: {
      JDate,
        MedicineExamineLossModal
    },
    data () {
      return {
        description: '药品报损单表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
            {
                title:'业务员',
                align:"center",
                dataIndex: 'createBy'
            },
            {
                title:'报损日期',
                align:"center",
                dataIndex: 'createTime'
            },
          {
            title:'批准文号',
            align:"center",
            dataIndex: 'yid'
          },
          {
            title:'药品名称',
            align:"center",
            dataIndex: 'yname'
          },
            {
                title:'报损数量',
                align:"center",
                dataIndex: 'bnumber'
            },
            {
                title:'报损原因',
                align:"center",
                dataIndex: 'breason'
            },
            {
                title:'备注',
                align:"center",
                dataIndex: 'remarks'
            },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/medicine/medicineLoss/list?status=0",
          delete: "/medicine/medicineLoss/delete",
          deleteBatch: "/medicine/medicineLoss/deleteBatch",
          exportXlsUrl: "/medicine/medicineLoss/exportXls",
          importExcelUrl: "medicine/medicineLoss/importExcel",
        },
        dictOptions:{
        },
      }
    },
      created() {
      },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
        ynamefun(){
            this.queryParam.yname='*'+this.queryParams.yname+'*';
        }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>